<?php

namespace admin\models;

use Yii;

/**
 * This is the model class for table "mm_user_photo".
 *
 * @property integer $mp_id
 * @property integer $mu_id
 * @property string $mp_main
 * @property string $mp_other
 *
 * @property Info $mu
 */
class UserPhoto extends \yii\db\ActiveRecord
{

    public $url;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'mm_user_photo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['mu_id'], 'integer'],
//            [['mp_main','mp_other'],'required'],
            [['mp_main', 'mp_other','url'], 'string', 'max' => 500],
            [['mu_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserInfo::className(), 'targetAttribute' => ['mu_id' => 'mi_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'mp_id' => '相片id',
            'mu_id' => '用户id',
            'mp_main' => '主要照片',
            'mp_other' => '其他照片',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMu()
    {
        return $this->hasOne(UserInfo::className(), ['mi_id' => 'mu_id']);
    }
}
